home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / examples / misc / xnothing.pro < prev    next >
Encoding:
Text File  |  1997-07-08  |  6.6 KB  |  221 lines

  1. ; $Id: xnothing.pro,v 1.5 1997/01/15 04:21:02 ali Exp $
  2. ;
  3. ; Copyright (c) 1991-1997, Research Systems, Inc.  All rights reserved.
  4. ;    Unauthorized reproduction prohibited.
  5. ;+
  6. ; NAME:
  7. ;    XNOTHING
  8. ;
  9. ; PURPOSE:
  10. ;    A demonstration of all the IDL widgets.  This routine demonstrates
  11. ;    everything without actually doing anything useful.
  12. ;
  13. ; CATEGORY:
  14. ;    Widgets, demo.
  15. ;
  16. ; CALLING SEQUENCE:
  17. ;    XNOTHING
  18. ;
  19. ; OUTPUTS:
  20. ;    None.
  21. ;
  22. ; COMMON BLOCKS:
  23. ;    None.
  24. ;
  25. ; RESTRICTIONS:
  26. ;    None.
  27. ;
  28. ; MODIFICATION HISTORY:
  29. ;    October, 1990, A.B.
  30. ;    Revised to work with XMANAGER, 3 January 1991
  31. ;    Modified to handle changed event names.
  32. ;
  33. ;-
  34.  
  35. pro xnothing_event, ev
  36.  
  37.   widget_control, ev.id, get_uvalue=value
  38.   if (n_elements(value) eq 0) then value = ''
  39.   name = strmid(tag_names(ev, /structure_name), 7, 4)
  40.   case (name) of
  41.   "BUTT": begin
  42.     if (value eq "DONE") then begin
  43.       WIDGET_CONTROL, /destroy, ev.top
  44.       return
  45.     endif
  46.     if (ev.select eq 0) then begin
  47.       value = value + ' (released)'
  48.     endif else begin
  49.       value = value + ' (selected)'
  50.     endelse
  51.     endcase
  52.   "DRAW": begin
  53.     value = string(format="(A,' X(', I0, ')', ' Y(', I0, ')', ' Press('," $
  54.         + "I0, ')', ' Release(', I0, ')')", value, ev.x, ev.y, $
  55.         ev.press, ev.release)
  56.     end
  57.   "SLID": value = ev.value
  58.   "TEXT": widget_control, ev.id, get_value=value, set_value=''
  59.   "LIST": value=value[ev.index]
  60.   else:
  61.   endcase
  62.  
  63.   WIDGET_CONTROL, ev.top, get_uvalue=out_text
  64.   WIDGET_CONTROL, out_text , set_value=name + ': ' + string(value),/append
  65. end
  66.  
  67.  
  68.  
  69. pro xnothing
  70.  
  71.   swin = !d.window    ;Previous window
  72.  
  73.   base = WIDGET_BASE(title='XNothing', /row)
  74.   ; Setting the managed attribute indicates our intention to put this app
  75.   ; under the control of XMANAGER, and prevents our draw widgets from
  76.   ; becoming candidates for becoming the default window on WSET, -1. XMANAGER
  77.   ; sets this, but doing it here prevents our own WSETs at startup from
  78.   ; having that problem.
  79.   WIDGET_CONTROL, /MANAGED, base
  80.  
  81.   b1 = WIDGET_BASE(base, /frame, /column)
  82.   t1 = WIDGET_TEXT(b1, xsize=80, ysize=10, /SCROLL, $
  83.       value=[ 'Nothing Is Everything:', $
  84.     '', $
  85.     '      This is a demonstration of every widget availible', $
  86.     '    under the IDL widget facility. Manipulating the widgets', $
  87.     '    causes messages to be written to this window. Try pushing', $
  88.     '    the buttons, moving the slider, clicking the mouse inside', $
  89.     '    the drawing area, typing inside the 1 line text area', $
  90.     "    (don't forget to type return), or selecting an item in the", $
  91.     '    scrolling list. To exit this demo, press the DONE button.' ])
  92.   WIDGET_CONTROL, base, set_uvalue=t1
  93.  
  94.   b2 = WIDGET_BASE(base, /frame, /column, space=30)
  95.  
  96.  
  97.   t1 = widget_base(b1, /row)
  98.   t2 = widget_label(t1, value = 'Text (Input/Output):')
  99.   intext = widget_text(t1, /editable, xsize=50, ysize=1)
  100.  
  101.   draw = widget_draw(b1, xsize=320, ysize=256, /button_events)
  102.  
  103.   t1=widget_label(b1, value='Text (Read-only)')
  104.   t1 = [  '    ROUTINE:', $
  105.     '         DILATE(Image, Structure [, X_0, Y_0])', $
  106.     '', $
  107.     '    DESCRIPTION:', $
  108.     '         The DILATE  function  implements  the  morphologic  dilation', $
  109.     '         operator on both binary and gray scale images.', $
  110.     '', $
  111.     '    ARGUMENTS:', $
  112.     '      Image:', $
  113.     '          The array upon which the operation is to be performed.   If', $
  114.     '         the  parameter is not of byte type, a temporary byte copy is', $
  115.     '         obtained. If neither keyword GRAY or VALUES is present,  the', $
  116.     '         image  is considered a binary image with all non-zero pixels', $
  117.     '         considered as 1.', $
  118.     '', $
  119.     '      Structure:', $
  120.     '          The structuring element which may be a one  or  two  dimen-', $
  121.     '         sional  array.   Elements  are interpreted as binary: values', $
  122.     '         are either zero or non-zero.', $
  123.     '', $
  124.     '      X_0, Y_0:', $
  125.     '          Optional parameters specifying the row and  column  coordi-', $
  126.     "         nate  of  the structuring element's origin.  If omitted, the", $
  127.     '         origin is set to the center,  (  N_X / 2 ,  N_Y  /  2   )  ,', $
  128.     '         where N_X and N_Y are the dimensions of the structuring ele-', $
  129.     '         ment array.  The origin need not be within  the  structuring', $
  130.     '         element.', $
  131.     '', $
  132.     '    KEYWORDS:', $
  133.     '      GRAY:', $
  134.     '          a flag which,  if  present,   indicates  that  gray  scale,', $
  135.     '         rather  than binary dilation is requested. Non-zero elements', $
  136.     '         of Structure parameter determine the  shape  of  structuring', $
  137.     '         element  (neighborhood).  If VALUES is not present, all ele-', $
  138.     '         ments of the structuring element are 0, yielding the  neigh-', $
  139.     '         borhood maximum operator.', $
  140.     '', $
  141.     '      VALUES:', $
  142.     '          an array of the same dimensions as Structure providing  the', $
  143.     '         values of the structuring element.  Presence of this parame-', $
  144.     '         ter implies gray scale dilation.  Each pixel of  the  result', $
  145.     '         is  the  maximum of the sum of the corresponding elements of', $
  146.     '         VALUE overlaid with Image.']
  147.  
  148.   t1 = widget_text(b1, ysize=14, xsize=80,/scroll, value=t1)
  149.  
  150.  
  151.   t1 = widget_button(b2, value="Done", uvalue = "DONE")
  152.   t1 = widget_button(b2, value = 'Push Button', uvalue = 'Push Button')
  153.  
  154.   t1 = widget_slider(b2, title='Slider')
  155.  
  156.   t2 = widget_base(b2, /COLUMN)
  157.   list_names= [ 'ABS', $
  158.     'ACOS', $
  159.     'ALOG', $
  160.     'ALOG10', $
  161.     'ASIN', $
  162.     'ASSOC', $
  163.     'ATAN', $
  164.     'AXIS', $
  165.     'BESELI', $
  166.     'BESELJ', $
  167.     'BESELY', $
  168.     'BINDGEN', $
  169.     'BREAKPOINT', $
  170.     'BYTARR', $
  171.     'BYTE', $
  172.     'BYTEORDER', $
  173.     'BYTSCL', $
  174.     'CALL_EXTERNAL', $
  175.     'CD', $
  176.     'CHECK_MATH', $
  177.     'CINDGEN', $
  178.     'CLOSE', $
  179.     'COLOR_CONVERT', $
  180.     'COMPLEX', $
  181.     'COMPLEXARR', $
  182.     'CONJ', $
  183.     'CONTOUR', $
  184.     'CONVOL', $
  185.     'COS', $
  186.     'COSH', $
  187.     'CURSOR', $
  188.     'DBLARR', $
  189.     'DEFINE_KEY', $
  190.     'DEFSYSV', $
  191.     'DELETE_SYMBOL', $
  192.     'DELLOG' ]
  193.   t1 = WIDGET_LIST(t2, ysize=10, uvalue=list_names, value=list_names)
  194.  
  195.   t2 = widget_base(b2, /column)
  196.   t1 = widget_label(t2, value='Toggle Button Menu')
  197.   pets = [ 'Dog', 'Cat', 'Snake', 'Moose' ]
  198.   XMENU, pets, t2, /EXCLUSIVE, /FRAME, uvalue=pets
  199.  
  200.   t2 = widget_base(b2, /column)
  201.   t1 = widget_label(t2,value='Pulldown Menu')
  202.   xpdmenu, [ '/Colors/ {', '  /Red/', '  /Green/', '  /Blue/ {', $
  203.     '    /Light/ Light Blue', '    /Medium/ Medium Blue', $
  204.     '    /Dark/ Dark Blue', '    /Royal/ Royal Blue', $
  205.     '    /Navy/ Navy Blue', '  }', '}' ], t2
  206.  
  207.   widget_control, base, /realize
  208.  
  209.   WIDGET_CONTROL, get_value=window, draw
  210.   openr, u, filepath('abnorm.dat', subdir=["examples", "data"]), /get_lun
  211.   a=bytarr(64,64)
  212.   readu,u,a
  213.   free_lun, u
  214.   wset, window
  215.   loadct,3
  216.   shade_surf,rebin(a,32,32)
  217.   wset, swin
  218.  
  219.   XMANAGER, 'XNOTHING', base, /NO_BLOCK
  220. end
  221.